package nameless.aistudy.common.enumeration.statistics;

public enum StatisticsTypeEnum {

    // 个人信息-综合统计 (13_02_02)
    // 个人信息-综合统计-打卡 (13_02_02_01)
    CONTINUOUS_CHECKIN_DAYS(13_02_02_01_00_01L,"连续打卡天数"),

    // 英语学习相关统计类型 (13_03_01)
    // 英语学习综合统计 (13_03_01_00)
    SUBJECT_ENGLISH_STUDY_DURATION(13_03_01_00_00_01L, "英语学习时长"),
    // 英语-词汇模块统计 (13_03_01_01)
    SUBJECT_ENGLISH_VOCABULARY_STUDY_DURATION(13_03_01_01_00_01L, "英语词汇学习时长"),
    SUBJECT_ENGLISH_VOCABULARY_LEARN(13_03_01_01_00_02L, "英语词汇学习量"),
    SUBJECT_ENGLISH_VOCABULARY_REVIEW(13_03_01_01_00_03L, "英语词汇复习量"),
    SUBJECT_ENGLISH_VOCABULARY_MASTERED(13_03_01_01_00_04L, "英语词汇掌握量"),
    // 英语-阅读模块统计 (13_03_01_02)
    SUBJECT_ENGLISH_READING_DURATION(13_03_01_02_00_01L, "英语阅读时长"),
    // 英语-写作模块统计 (13_03_01_03)
    SUBJECT_ENGLISH_WRITING_DURATION(13_03_01_03_00_01L, "英语写作时长"),
    SUBJECT_ENGLISH_WRITING_COMPOSITION_COUNT(13_03_01_03_00_02L, "英语写作篇数"),
    SUBJECT_ENGLISH_WRITING_WORD_COUNT(13_03_01_03_00_03L, "英语写作词数");

    private final long id;
    private final String description;

    StatisticsTypeEnum(long id, String description) {
        this.id = id;
        this.description = description;
    }

    public long getId() {
        return id;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据ID查找对应的枚举值
     * @param id 统计类型ID
     * @return 对应的StatisticsType枚举
     * @throws IllegalArgumentException 如果找不到对应的枚举值
     */
    public static StatisticsTypeEnum fromId(long id) {
        for (StatisticsTypeEnum type : values()) {
            if (type.id == id) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的统计类型ID: " + id);
    }

    /**
     * 检查给定的ID是否存在对应的枚举值
     * @param id 要检查的ID
     * @return 如果存在返回true，否则返回false
     */
    public static boolean containsId(long id) {
        for (StatisticsTypeEnum type : values()) {
            if (type.id == id) {
                return true;
            }
        }
        return false;
    }
}